﻿@{
    ViewBag.Title = "Common Command";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
        <ol class="breadcrumb">
    <li><a href="/Home.html">Home</a></li>
    <li><a href="/WebApp/WebApi"> Sanelib WebApp</a></li>
    <li class="active">Authentication Service</li>
</ol>
      
            <div id="introduction">
                <h1 class="text-left">Services</h1>
                <h4>IAuthnticationService Interface</h4>
                <p>In the IAuthnticationService defined to the PasswroMathches return to the bool value see in the example</p>
                <pre><code>
public interface IAuthenticationService
{
	bool PasswordMatches(MemberView user, string password);
}
</code></pre>
            </div>
            <div id="start">
                <h4>AuthnticationService Class</h4>
                <p>In the AuthnticationServices class implements a IAuthenticationService interface see in the example</p>
                <pre><code>
public class AuthenticationService : IAuthenticationService
{....}
</code></pre>
                <p>In this class also defined to the ICryptographer is provides services to the get the hash password see in the example</p>
                <pre><code>
private readonly ICryptographer _cryptographer;
public AuthenticationService(ICryptographer cryptographer)
{
	_cryptographer = cryptographer;
}
   
public bool PasswordMatches(MemberView user, string password)
{
    var passwordHash = _cryptographer.GetPasswordHash(password, user.PasswordSalt);
    return passwordHash.Equals(user.PasswordHash);
}
</code></pre>
                <p>here, the PasswordMatches is called from the <a href="/WebApp/Account" class="btn-link">AccountController</a>, <a href="/WebApp/AccountRecovery">AccountRecoveryController</a> and the <a href="/WebApp/UserSession">UserSession</a> for the User Credentials</p>
                <p>and at last the return a user credential true if the passwordHash is equals to the user PasswordHash</p>
            </div>
       